<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>register.html</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
    <link rel="stylesheet" href="../css/footer.css">
    <link rel="stylesheet" href="../css/login.css">
    <link rel="stylesheet" href="../css/header_login.css">
    <link rel="icon" href="../images/小图标.jpg">
    <script>
       function register(){
            var name = document.querySelector('#nickName').value
            var pwd = document.querySelector('#pwd').value
            //1.通过AJAX访问服务器接口，进行注册
            $.ajax({
                url:'http://localhost:3000/api/register',
                type:'post',
                data:{userName:name,userPwd:pwd},
                success:function(result){
                    if(result.message == 'ok'){
                        //2.跳转到登录页面
                        alert('注册成功！')
                        location.href = 'http://localhost:5504/html/login.html'
                    }else{
                        alert('注册失败！')
                    }
                }
            })
           
        }
    </script>
</head>
<body>
    <header>
        <div>
            <a href="../html/index.html"><img src="../images/login.png" alt=""></a>
    </header>
    <div class="login-background">
        <div class="content-box">
            <div class="middle-box">
            <div class="form-login-box">
                <div class="login-regi-title">
                    <h2 class="active">用户注册</h2>
                </div>
                <div class="form-content">
                    <form action="" method="post" class="myform">
                        <dl class="register_row">
                           <dd><input name="userEmail" id="email" type="text" class="register_input" placeholder="请输入您的邮箱" onclick="checkEmail()"></dd>
                           <dd><div id="email_prompt"></div></dd>
                         </dl>
                         <dl class="register_row">
                            <dd><input name="userName" id="nickName" type="text" class="register_input" placeholder="请输入账号" onclick="checkName()"></dd>
                           <dd><div id="nickName_prompt"></div></dd>
                         </dl>
                        <dl class="register_row">
                            <dd><input name="userPwd" id="pwd" type="password" class="register_input" placeholder="设定密码" onchange="checkPwd()"></dd>
                            <dd><div id="pwd_prompt"></div></dd>
                        </dl>
                        <dl class="register_row"> 
                            <dd><input id="repwd" type="password" placeholder="再输入一次密码" class="register_input" onkeyup="checkRepwd()"></dd>
                           <dd><div id="repwd_prompt"></div></dd>
                        </dl>
                        <dl class="register_row"> 
                            <dd><input name="userValidCode" id="validCode" type="text" placeholder="请输入验证码" class="register_input"></dd>
                           <dd><div id="validCode_prompt"></div></dd>
                           <dd><input type="button" value="获取验证码" ></dd>
                        </dl>   
                        <dl>
                            <input type="checkbox" id="rule">
                            我已阅读并同意
                            <a href="https://www.lecake.com/shop/help-41.html" class="regxie">《诺心lecake用户服务协议》</a>
                        </dl>
                        </div><input type="button" class="register-button"  id="registerBtn" value="注册" onclick="register()">
                        </form>
                </div>
            </div>
        </div>
        </div>
    </div>
        
    <footer>
            <div class="footer">
                <img class="footer-logo" src="../images/logo.png" height="23" width="200" alt="">
                <div class="footer-nav">
                    <a>诺心公告</a>
                    <span>|</span>
                    <a>关于诺心</a>
                    <span>|</span>
                    <a>客服服务</a>
                    <span>|</span>
                    <a>生产经营资质</a>
                    <span>|</span>
                    <a>公告专区</a>
                </div>
                <div class="footer-icon">
                    <a href="http://weibo.com/21cake" target="_blank">
                        <img src="../images/footericon-01.png">
                    </a>
                    <a class="footer-weixin">
                        <div class="footer-erweima footer-weixin-erweima">
                            <img src="../images/erweima.png">
                        </div>
                        <img src="../images/footericon-02.png">
                    </a>
                    <a class="footer-app">
                        <div class="footer-erweima footer-app-erweima">
                            <img src="../images/footer-erweima.png">
                        </div>
                        APP
                    </a>
                </div>
    
                <div class="footer-text">
                    <span>订购专线：4001-578-578（服务时间 09:00–21:00）</span>
                    <span>客服电话：021-23099721（全国） | services@lecake.com（邮箱）</span>
                    <span>杭州/广州：提前5小时预订；北京：提前6小时预订；上海：提前5.5-6小时预订；天津/苏州/无锡/深圳：提前8小时预订（部分偏远地区除外，当日22点以后订单，于次日8点开始审核） </span>
                    <span>当日蛋糕配送截止下单时间：北京：16:50；上海：16:30；杭州/广州：13:50；天津：10:30；苏州/无锡/深圳：11:00</span>
                    <span>网站注册公司名称: 诺心食品（上海）有限公司  地址: 上海市徐汇区虹漕路68号锦和中心7楼A、C单元 </span>
                </div>
                <div class="footer-copyright">
                    <span>Copyright© 诺心leCake蛋糕官网商城 2010-2022, 版权所有 <a style="color: #9a9a9a" target="_blank" href="https://beian.miit.gov.cn/#/Integrated/index">沪ICP备10211730号-2</a></span>
                </div>
            </div>
        </footer>
</body>
<script src="../js/register.js"></script>
</html>